package com.old.mapper;


import com.github.pagehelper.Page;
import com.old.annotation.AutoFill;
import com.old.dto.CommentDTO;
import com.old.dto.CommentQueryDTO;
import com.old.entity.Comment;
import com.old.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface CommentMapper {

    /**
     * 根据postId查询评论
     * @param comment
     * @return
     */
    List<Comment> list(Comment comment);

    /**
     * 添加评论
     * @param commentDTO
     */
    @AutoFill(OperationType.INSERT)
    void save(CommentDTO commentDTO);

    /**
     * 分页查询评论
     * @param commentQueryDTO
     * @return
     */
    @Select("SELECT * FROM comment WHERE postId = #{postId} ORDER BY create_time DESC")
    Page<Comment> listPage(CommentQueryDTO commentQueryDTO);
}
